// pages/my/mylogin/myResult/myResult.js
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
      url:'',
    state1: true,
    state2: false,
    completeColor: false,
    collectionList:[],
    showList:[],
    courseData:""
  },

  changeStatus: function(e){
      let id = e.currentTarget.dataset['cid'];
      let that = this;
    wx.request({
        url: that.data.url + 'collectCourses/editById?id='+id,
    })
    that.query();
    wx.navigateTo({
          url: '/pages/my/mylogin/paysuccess/paysuccess',
        })
  },

  switchState1: function(){
      console.log(11111);
    let aa=[]
    for(let ww of this.data.collectionList){
      if(ww.status!=0){
        aa.push(ww)
      }
    }
    this.setData({
      state1: true,
      state2: false,
      completeColor: false,
      showList:aa

    })
    return;
  },
  switchState2: function(){
    let aa=[]
    for(let ww of this.data.collectionList){
      if(ww.status==0){
        aa.push(ww)
      }
    }
    this.setData({
      state1: false,
      state2: true,
      completeColor: true,
      showList:aa
    })
  },
  query:function(){
    let user = wx.getStorageSync('userInfo');
    this.setData({
        url:app.globalData.URL
    })
    let that = this;
      wx.request({
          url: that.data.url + 'collectCourses/findByUserId?id='+user.id,
          success(resp) {
              that.setData({
                  "collectionList": resp.data.data
              })
              that.switchState1();
          }
      })

  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
      let that = this;
      that.query();
    
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})